package com.dmyang.service.impl;

import com.dmyang.dao.HyUserMapper;
import com.dmyang.entity.HyUser;
import com.dmyang.entity.HyUserExample;
import com.dmyang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by brss on 2017/8/8.
 */
@Service("userServiceImpl")
public class UserServiceImpl implements UserService {
    @Autowired
    private HyUserMapper userMapper;

    /**
     * 检查用户登录
     * @return
     * @throws Exception
     */
    @Override
    public HyUser checkUserLogin(HyUser user) throws Exception {
        HyUserExample example = new HyUserExample();
        HyUserExample.Criteria criteria = example.createCriteria();
        criteria.andEmailEqualTo(user.getEmail());
        //查询
        List<HyUser> result = userMapper.selectByExample(example);
        if (result != null){
            return result.get(0);
        }else {
            return null;
        }
    }
}
